package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.bean.GhListBean;
import com.xianbeiying.app.ckgl.util.DataUtil;

import java.util.ArrayList;

/**
 *  温室种类数据
 */
public class GhSettingAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<GhListBean.VBean.GREENHOUSEBean> greenhouseBeen;
    public GhSettingAdapter(Context context,ArrayList<GhListBean.VBean.GREENHOUSEBean> greenhouseBeen) {
        this.context = context;
        this.greenhouseBeen=greenhouseBeen;
    }
    private String [] str;
    private int selectId;
    public ArrayList<Boolean> arrayList;
    public ArrayList<Boolean> getArrayList() {
        return arrayList;
    }
    public void setArrayList(ArrayList<Boolean> arrayList) {
        this.arrayList = arrayList;
    }
    @Override
    public int getCount(){
        return greenhouseBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_ghseting, parent, false);
            holder = new ViewHolder();
            holder.iv_gh_delete=(ImageView) convertView.findViewById(R.id.iv_gh_delete);
            holder.tv_gh_dp=(TextView) convertView.findViewById(R.id.tv_gh_dp);
            holder.tv_gh_cp=(TextView) convertView.findViewById(R.id.tv_gh_cp);
            holder.tv_gh_jd=(TextView) convertView.findViewById(R.id.tv_gh_jd);
            holder.tv_gh_mj=(TextView) convertView.findViewById(R.id.tv_gh_mj);
            holder.tv_gh_rq=(TextView) convertView.findViewById(R.id.tv_gh_rq);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_gh_dp.setText("大棚名称:"+greenhouseBeen.get(position).getHouseName());
        if(greenhouseBeen.get(position).getCrop()!=null)
        holder.tv_gh_cp.setText("种植产品:"+greenhouseBeen.get(position).getCrop().getCropName());
        holder.tv_gh_jd.setText("种植阶段:"+(greenhouseBeen.get(position).getGrowType()==0?"育苗":"种植"));
        holder.tv_gh_mj.setText("种植面积:"+greenhouseBeen.get(position).getPlantArea()+"");
        holder.tv_gh_rq.setText("种植日期:"+DataUtil.paserTime(greenhouseBeen.get(position).getPlantTime()+"","yyyy-MM-dd"));
        holder.iv_gh_delete.setVisibility(View.GONE);
        return convertView;
    }
    private class ViewHolder{
       ImageView iv_gh_delete;
       TextView tv_gh_dp;
        TextView tv_gh_cp;
        TextView tv_gh_jd;
        TextView tv_gh_mj;
        TextView tv_gh_rq;
    }
}
